1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module soup.ContentSniffer; 26 27 private import glib.ConstructionException; 28 private import glib.HashTable; 29 private import glib.Str; 30 private import glib.c.functions; 31 private import gobject.ObjectG; 32 private import soup.Buffer; 33 private import soup.Message; 34 private import soup.SessionFeatureIF; 35 private import soup.SessionFeatureT; 36 private import soup.c.functions; 37 public import soup.c.types; 38 39 40 /** */ 41 public class ContentSniffer : ObjectG, SessionFeatureIF 42 { 43 /** the main Gtk struct */ 44 protected SoupContentSniffer* soupContentSniffer; 45 46 /** Get the main Gtk struct */ 47 public SoupContentSniffer* getContentSnifferStruct(bool transferOwnership = false) 48 { 49 if (transferOwnership) 50 ownedRef = false; 51 return soupContentSniffer; 52 } 53 54 /** the main Gtk struct as a void* */ 55 protected override void* getStruct() 56 { 57 return cast(void*)soupContentSniffer; 58 } 59 60 /** 61 * Sets our main struct and passes it to the parent class. 62 */ 63 public this (SoupContentSniffer* soupContentSniffer, bool ownedRef = false) 64 { 65 this.soupContentSniffer = soupContentSniffer; 66 super(cast(GObject*)soupContentSniffer, ownedRef); 67 } 68 69 // add the SessionFeature capabilities 70 mixin SessionFeatureT!(SoupContentSniffer); 71 72 73 /** */ 74 public static GType getType() 75 { 76 return soup_content_sniffer_get_type(); 77 } 78 79 /** 80 * Creates a new #SoupContentSniffer. 81 * 82 * Returns: a new #SoupContentSniffer 83 * 84 * Since: 2.28 85 * 86 * Throws: ConstructionException GTK+ fails to create the object. 87 */ 88 public this() 89 { 90 auto __p = soup_content_sniffer_new(); 91 92 if(__p is null) 93 { 94 throw new ConstructionException("null returned by new"); 95 } 96 97 this(cast(SoupContentSniffer*) __p, true); 98 } 99 100 /** 101 * Gets the number of bytes @sniffer needs in order to properly sniff 102 * a buffer. 103 * 104 * Returns: the number of bytes to sniff 105 * 106 * Since: 2.28 107 */ 108 public size_t getBufferSize() 109 { 110 return soup_content_sniffer_get_buffer_size(soupContentSniffer); 111 } 112 113 /** 114 * Sniffs @buffer to determine its Content-Type. The result may also 115 * be influenced by the Content-Type declared in @msg's response 116 * headers. 117 * 118 * Params: 119 * msg = the message to sniff 120 * buffer = a buffer containing the start of @msg's response body 121 * params = return 122 * location for Content-Type parameters (eg, "charset"), or %NULL 123 * 124 * Returns: the sniffed Content-Type of @buffer; this will never be %NULL, 125 * but may be "application/octet-stream". 126 * 127 * Since: 2.28 128 */ 129 public string sniff(Message msg, Buffer buffer, out HashTable params) 130 { 131 GHashTable* outparams = null; 132 133 auto retStr = soup_content_sniffer_sniff(soupContentSniffer, (msg is null) ? null : msg.getMessageStruct(), (buffer is null) ? null : buffer.getBufferStruct(), &outparams); 134 135 params = new HashTable(outparams); 136 137 scope(exit) Str.freeString(retStr); 138 return Str.toString(retStr); 139 } 140 }